<?php

/**
 * model_pay
 */

class Model_pay extends YOU {

	public function __construct()
	{
		parent::__construct();
	}

	/** 取得配置信息 **/
	public function getSet()
	{
		$row = $this->db->fetchRow("SELECT * FROM `tbl_pay_set`");
		$row['set_unsub']      = unserialize($row['set_unsub']);
		$row['set_jobsub']     = unserialize($row['set_jobsub']);
		$row['set_specialsub'] = unserialize($row['set_specialsub']);
		$row['set_unitem']     = unserialize($row['set_unitem']);
		$row['set_uncheck']    = unserialize($row['set_uncheck']);
		$row['set_adjustcost'] = unserialize($row['set_adjustcost']);
        $row['set_dutyarea'] = unserialize($row['set_dutyarea']);
		return $row;
	}

	/** 写入配置信息 **/
	public function Set($info)
	{
		$row = $this->db->do_update("tbl_pay_set", $info, "set_id='1'");

		return $row;
	}

	/** 读取年级作业补贴设置 **/
	public function getWork($grade_id)
	{
		$row = $this->db->fetchRow("SELECT * FROM `tbl_pay_work` WHERE grade_id='{$grade_id}'");

		return $row;
	}

	/** 总结数据 **/
	public function getEndInfo($semester_id)
	{
		$row = $this->db->fetchRow("SELECT * FROM `tbl_pay` WHERE semester_id='{$semester_id}' AND pay_type='end'");
		return $row;
	}

	/** 月数据 **/
	public function getMonthInfo($semester_id, $pay_month)
	{
		$row = $this->db->fetchRow("SELECT * FROM `tbl_pay` WHERE semester_id='{$semester_id}' AND pay_type='month' AND pay_month='{$pay_month}'");

		return $row;
	}

	/** 得到月份 **/
	public function getMonthAll(){
		$lists = $this->db->fetchAll("SELECT pay_month FROM `tbl_pay` GROUP BY pay_month");
		foreach ($lists as $key => $value){
			if (!empty($value['pay_month'])){
				$data[$value['pay_month']]++;
			}
		}

		return $data;
	}


}



?>